﻿using Newtonsoft.Json;
using System.Dynamic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Web;
using YPD.Common.Model;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;

//namespace YPD.Common.Service
//{
//    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
//    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
//    [JavascriptCallbackBehavior(UrlParameterName = "callback")]
//    [ServiceContract]
//    public class Basic
//    {
//        [WebInvoke(UriTemplate = "Test", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
//        //  [WebGet(UriTemplate = "Test/{str}", ResponseFormat = WebMessageFormat.Json)]
//        public ReturnPakect<string> Test(int I, int O,params string[] str)
//        {
            

//            dynamic obj =new ExpandoObject();

//            if (O == 1)
//                obj.Data = "1111";
//            else
//            {
//                obj.Data = new string[O];

//                for (int i = 1; i <= O; i++)
//                {
//                    obj.Data[i - 1] = "test string " + i.ToString();
//                }
//            }


           
           
//            var rst = new ReturnPakect<string>();
//           // rst.SetSuccess( obj);
//            //var tt = JsonConvert.SerializeObject(obj);

//            //using (MemoryStream stream = new MemoryStream())
//            //{
//            //    DataContractJsonSerializer jsonSerialize = new DataContractJsonSerializer(obj);
//            //    jsonSerialize.WriteObject(stream, obj);
//            //    rst.SetSuccess(Encoding.UTF8.GetString(stream.ToArray()));
//            //}

//           rst.SetSuccess(JsonConvert.SerializeObject(obj));
//            return rst;
//        }
       
//    }
//}